home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / CERTCARC.AS_ / certcarc.asp
Encoding:
Text File  |  2003-02-21  |  22.7 KB  |  583 lines

  1. ∩╗┐<%@ CODEPAGE=65001 'UTF-8%>
  2. <%' certcarc.asp - (CERT)srv web - install (CA) (R)oot (C)ertificate
  3.   ' Copyright (C) Microsoft Corporation, 1998 - 1999 %>
  4. <!-- #include FILE=certsbrt.inc -->
  5. <!-- #include FILE=certdat.inc -->
  6. <%
  7.     On Error Resume Next
  8.     ' from \nt\public\sdk\inc\certcli.h
  9.     Const CR_OUT_BASE64HEADER=&H00000000
  10.     Const CR_OUT_BASE64      =&H00000001
  11.     Const CR_OUT_BINARY      =&H00000002
  12.     Const CR_OUT_CHAIN       =&H00000100
  13.  
  14.     Const CATYPE_ENTERPRISE_ROOTCA=0
  15.     Const CATYPE_ENTERPRISE_SUBCA=1
  16.     Const CATYPE_STANDALONE_ROOTCA=3
  17.     Const CATYPE_STANDALONE_SUBCA=4
  18.     Const CATYPE_UNKNOWN_CA=5
  19.  
  20.     ' from \nt\private\ca\include\certlib.h
  21.     Const GETCERT_CAXCHGCERT=1    ' == C/C++ TRUE value
  22.     Const GETCERT_CASIGCERT=False
  23.  
  24.     Const CR_GEMT_HRESULT_STRING     =&H00000001
  25.  
  26.     Const CR_PROP_CASIGCERTCOUNT=11
  27.     Const CR_PROP_CASIGCERTCHAIN=13
  28.     Const CR_PROP_CACERTSTATE=19
  29.     Const CR_PROP_CRLSTATE=20
  30.     Const CR_PROP_DELTACRL=18
  31.  
  32.     Const PROPTYPE_LONG=1
  33.     Const PROPTYPE_BINARY=3
  34.     
  35.     Const CERT_VALID=3 ' == CA_DISP_VALID
  36.     Const CRL_AVAILABLE=3 ' == CA_DISP_VALID
  37.     Const CRL_OPTIONAL=4 ' == CA_DISP_INVALID
  38.     
  39.     ' Strings To Be Localized
  40.     Const L_InstallThisCACert_Message="Install this CA certificate"
  41.     Const L_InstallThisCACertChain_Message="Install this CA certificate chain"
  42.     Const L_InstallCACert_Message="Install CA certificate"
  43.     Const L_DownloadCert_Message="Download CA certificate"
  44.     Const L_DownloadChain_Message="Download CA certificate chain"
  45.     Const L_DownloadBaseCrl_Message="Download latest base CRL"
  46.     Const L_DownloadDeltaCrl_Message="Download latest delta CRL"
  47.  
  48.     Dim sCaInfo, rgCaInfo, nRenewals, rgCrlState, rgCertState, bFailed, nError, bDeltaCrl
  49.     Set ICertRequest=Server.CreateObject("CertificateAuthority.Request")
  50.  
  51.     ' get the number of renewals
  52.     bFailed=False
  53.     bDeltaCrl = True
  54.     nRenewals=ICertRequest.GetCAProperty(sServerConfig, CR_PROP_CASIGCERTCOUNT, 0, PROPTYPE_LONG, CR_OUT_BINARY)
  55.     If 0=Err.Number Then
  56.  
  57.         nRenewals=nRenewals-1
  58.  
  59.         ' get the key-reused state of the CRLs and the validity of the CA Certs
  60.         ReDim rgCrlState(nRenewals) ' 0 based size
  61.         ReDim rgCertState(nRenewals) ' 0 based size
  62.         For nIndex=0 To nRenewals
  63.             rgCrlState(nIndex)=ICertRequest.GetCAProperty(sServerConfig, CR_PROP_CRLSTATE, nIndex, PROPTYPE_LONG, CR_OUT_BINARY)
  64.             rgCertState(nIndex)=ICertRequest.GetCAProperty(sServerConfig, CR_PROP_CACERTSTATE, nIndex, PROPTYPE_LONG, CR_OUT_BINARY)
  65.         Next
  66.  
  67.         ' get the cert chain and save it on this page so the client can install it
  68.         If "IE"=sBrowser Then
  69.             Public sPKCS7
  70.             Dim sCertificate
  71.             sCertificate=ICertRequest.GetCACertificate(GETCERT_CASIGCERT, sServerConfig, CR_OUT_BASE64_HEADER Or CR_OUT_CHAIN)
  72.             sPKCS7=FormatBigString(sCertificate, "    sPKCS7=sPKCS7 & ")
  73.         End If
  74.     End If
  75.  
  76.     If Err.Number<>0 Then
  77.         ' CA may be down.
  78.         bFailed=True
  79.         nError=Err.Number
  80.     End If
  81.  
  82.     ICertRequest.GetCAProperty sServerConfig, CR_PROP_DELTACRL, 0, PROPTYPE_BINARY, CR_OUT_BASE64HEADER
  83.     If &H80070002=Err.Number Then
  84.         'delta crl is not available
  85.         bDeltaCrl = False
  86.     End If
  87.  
  88.     '-----------------------------------------------------------------
  89.     ' Format the big string as a concatenated VB string, breaking at the embedded newlines
  90.     Function FormatBigString(sSource, sLinePrefix)
  91.         Dim sResult, bCharsLeft, nStartChar, nStopChar, chQuote
  92.         sResult=""
  93.         chQuote=chr(34)
  94.         bCharsLeft=True
  95.         nStopChar=1
  96.  
  97.         While (bCharsLeft)
  98.             nStartChar=nStopChar
  99.             nStopChar=InStr(nStopChar, sSource, vbNewLine)
  100.  
  101.             If (nStopChar>0) Then
  102.                 sResult=sResult & sLinePrefix & chQuote & Mid(sSource, nStartChar, nStopChar-nStartChar) & chQuote & " & vbNewLine"
  103.  
  104.                 If (nStopChar>=Len(sSource)-Len(vbNewLine)) Then
  105.                     bCharsLeft=False
  106.                 End If
  107.  
  108.             Else
  109.                 bCharsLeft=False
  110.             End if
  111.             sResult=sResult & vbNewLine
  112.             nStopChar=nStopChar+Len(vbNewLine)
  113.         Wend
  114.         FormatBigString=sResult
  115.     End Function
  116.  
  117.     '-----------------------------------------------------------------
  118.     ' Walk through the CRL validity list and return the nearest valid CRL
  119.     Function GetGoodCrlIndex(nIndex)
  120.         Dim nSource
  121.         nSource=nRenewals-nIndex
  122.         While (nSource>0 And CRL_AVAILABLE<>CInt(rgCrlState(nSource)))
  123.             nSource=nSource-1
  124.         Wend
  125.         GetGoodCrlIndex=nSource
  126.     End Function
  127. %>
  128. <HTML>
  129. <Head>
  130.     <Meta HTTP-Equiv="Content-Type" Content="text/html; charset=UTF-8">
  131.     <Title>Microsoft Certificate Services</Title>
  132. </Head>
  133. <Body BgColor=#FFFFFF Link=#0000FF VLink=#0000FF ALink=#0000FF><Font ID=locPageFont Face="Arial">
  134.  
  135. <Table Border=0 CellSpacing=0 CellPadding=4 Width=100% BgColor=#008080>
  136. <TR>
  137.     <TD><Font Color=#FFFFFF><LocID ID=locMSCertSrv><Font Face="Arial" Size=-1><B><I>Microsoft</I></B> Certificate Services  --  <%=sServerDisplayName%>  </Font></LocID></Font></TD>
  138.     <TD ID=locHomeAlign Align=Right><A Href="/certsrv"><Font Color=#FFFFFF><LocID ID=locHomeLink><Font Face="Arial" Size=-1><B>Home</B></Font></LocID></Font></A></TD>
  139. </TR>
  140. </Table>
  141.  
  142. <%If True=bFailed Then %>
  143. <P ID=locPageTitle1><Font Color=#FF0000><B>Error</B></Font>
  144. <!-- Green HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR></Table>
  145.  
  146. <P ID=locErrorMsg> An unexpected error has occurred: 
  147. <%If nError=&H800706BA Or nError=&H80070005 Then%>
  148.     <LocID ID=locSvcNotStarted>The Certification Authority Service has not been started.</LocID>
  149. <%Else%>
  150.     <%=ICertRequest.GetErrorMessageText(nError, CR_GEMT_HRESULT_STRING)%>
  151. <%End If%>
  152.  
  153. <%Else 'True<>bFailed%>
  154.  
  155. <Form Name=UIForm>
  156. <P ID=locPageTitle2> <B> Download a CA Certificate, Certificate Chain, or CRL</B>
  157. <!-- Green HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR></Table>
  158.  
  159. <P>
  160. <%If "IE"=sBrowser Then%>
  161. <LocID ID=locInstallIE>
  162. To trust certificates issued from this certification authority,
  163. <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  164.     OnContextMenu="return false;"
  165.     OnMouseOver="window.status='<%=L_InstallThisCACertChain_Message%>';return true;"
  166.     OnMouseOut="window.status='';return true;"
  167.     OnKeyDown="if (13==event.keyCode) {preInstall();return false;} else if (9==event.keyCode) {return true;};return false;"
  168.     OnClick="preInstall();return false;"
  169.     >install this CA certificate chain</Span>.
  170. </LocID>
  171. <%ElseIf "NN"=sBrowser Then%>
  172. <LocID ID=locInstallNN>
  173. To trust certificates issued from this certification authority,
  174. <A Href="certnew.cer?ReqID=CACert&Renewal=<%=nRenewals%>&Mode=inst&Enc=b64"
  175.     OnMouseOver="window.status='<%=L_InstallThisCACert_Message%>';return true;"
  176.     OnMouseOut="window.status='';return true;"
  177.     >install this CA certificate</A>.
  178. </LocID>
  179. <%Else%>
  180. <LocID ID=locInstallTxt>
  181. To trust certificates issued from this certification authority, install this CA certificate chain.
  182. </LocID>
  183. <%End If%>
  184.  
  185. <P>
  186.  
  187. <LocID ID=locPrompt>To download a CA certificate, certificate chain, or CRL, select the certificate and encoding method.</B></LocID>
  188. <%If "Text"<>sBrowser Then%>
  189. <Table Border=0 CellSpacing=0 CellPadding=0>
  190.     <TR> <!--establish column widths. -->
  191.         <TD><Img Src="certspc.gif" Alt="" Height=1 Width=<%=L_LabelColWidth_Number%>></TD> <!-- label column, top border -->
  192.         <TD RowSpan=59><Img Src="certspc.gif" Alt="" Height=1 Width=4></TD>                <!-- label spacing column -->
  193.         <TD></TD>                                                                          <!-- field column -->
  194.     </TR>
  195.  
  196.     <TR>
  197.         <TD ID=locCaCertHead ColSpan=3><Font ID=Font_lbCaID Face="Arial" Size=-1><BR><Label For=lbCaID ID=Lable_lbCaID ><B>CA certificate:</B></Label></Font></TD>
  198.     </TR>
  199.     <TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR>
  200.     <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=6 Width=1></TD></TR>
  201.     <TR>
  202.         <TD Align=Right VAlign=Top ID=locCaCertLabel></TD>
  203.         <TD><Select Size=4 Name=lbCaInstance ID=lbCaID>
  204.                 <Option Value="0" Selected><LocID ID=locCurCertEntry>Current</LocID> <%If 0<>nRenewals Then%><LocID ID=locCaNameRen1>[<%=sServerDisplayName%>(<%=nRenewals%>)]</LocID><%Else%><LocID ID=locCaNameNoRen1>[<%=sServerDisplayName%>]</LocID><%End If%>
  205.                 <%For nIndex=1 To nRenewals%>
  206.                     <%If CERT_VALID=CInt(rgCertState(nRenewals-nIndex)) Then%>
  207.                 <Option Value="<%=nIndex%>"><LocID ID=locPrevCertEntry>Previous</LocID> <%If nIndex<>nRenewals Then%><LocID ID=locCaNameRen2>[<%=sServerDisplayName%>(<%=nRenewals-nIndex%>)]</LocID><%Else%><LocID ID=locCaNameNoRen2>[<%=sServerDisplayName%>]</LocID><%End If%>
  208.                     <%End If%>
  209.                 <%Next%>
  210.             </Select>
  211.         </TD>
  212.     </TR>
  213.     <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=4 Width=1></TD></TR>
  214.  
  215.     <TR>
  216.         <TD ID=locEncodingHead ColSpan=3><Font Face="Arial" Size=-1><BR><B>Encoding method:</B></Font></TD>
  217.     </TR>
  218.     <TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR>
  219.     <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=6 Width=1></TD></TR>
  220.     <TR><TD></TD>
  221.         <TD><Font ID=locEncDerFont Face="Arial">
  222.             <Input Type=Radio ID=rbDerEnc Name=rbEncoding Checked><Label For=rbDerEnc ID=locDerEnc0>DER</Label>
  223.             </Font>
  224.         </TD>
  225.     </TR>
  226.     <TR><TD></TD>
  227.         <TD><Font ID=locEncB64Font Face="Arial">
  228.             <Input Type=Radio ID=rbB64Enc Name=rbEncoding><Label For=rbB64Enc ID=locB64Enc0>Base 64</Label>
  229.             </Font>
  230.         </TD>
  231.     </TR>
  232.     <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=6 Width=1></TD></TR>
  233. </Table>
  234.     <%If "IE"=sBrowser Then%>
  235. <Table CellSpacing=0 CellPadding=0>
  236.     <TR><TD></TD>
  237.         <TD><Font ID=locDlCaCFont Face="Arial">
  238.             <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  239.                 OnContextMenu="return false;"
  240.                 OnMouseOver="window.status='<%=L_DownloadCert_Message%>'; return true;" 
  241.                 OnMouseOut="window.status=''; return true;" 
  242.                 OnKeyDown="if (13==event.keyCode) {handleGetCert();return false;} else if (9==event.keyCode) {return true;};return false;"
  243.                 OnClick="handleGetCert();return false;">
  244.             <LocID ID=locDownloadCert>Download CA certificate</LocID></Span></Font>
  245.         </TD>
  246.     </TR>
  247.     <TR><TD ColSpan=3 Height=3></TD></TR>
  248.  
  249.     <TR><TD></TD>
  250.         <TD><Font ID=locDlCaCpFont Face="Arial">
  251.             <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  252.                 OnContextMenu="return false;"
  253.                 OnMouseOver="window.status='<%=L_DownloadChain_Message%>'; return true;" 
  254.                 OnMouseOut="window.status=''; return true;" 
  255.                 OnKeyDown="if (13==event.keyCode) {handleGetChain();return false;} else if (9==event.keyCode) {return true;};return false;"
  256.                 OnClick="handleGetChain();return false;">
  257.             <LocID ID=locDownloadCertChain>Download CA certificate chain</LocID></Span></Font>
  258.         </TD>
  259.     </TR>
  260.     <TR><TD ColSpan=3 Height=3></TD></TR>
  261.  
  262.     <TR><TD></TD>
  263.         <TD><Font ID=locDlBaseCrlFont Face="Arial">
  264.             <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  265.                 OnContextMenu="return false;"
  266.                 OnMouseOver="window.status='<%=L_DownloadBaseCrl_Message%>'; return true;" 
  267.                 OnMouseOut="window.status=''; return true;" 
  268.                 OnKeyDown="if (13==event.keyCode) {handleGetBaseCrl();return false;} else if (9==event.keyCode) {return true;};return false;"
  269.                 OnClick="handleGetBaseCrl();return false;">
  270.             <LocID ID=locDownloadBaseCRL>Download latest base CRL</LocID></Span></Font>
  271.         </TD>
  272.     </TR>
  273.     <TR><TD ColSpan=3 Height=3></TD></TR>
  274.  
  275. <%If True=bDeltaCrl Then %>
  276.     <TR><TD></TD>
  277.         <TD><Font ID=locDlDeltaCrlFont Face="Arial">
  278.             <Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  279.                 OnContextMenu="return false;"
  280.                 OnMouseOver="window.status='<%=L_DownloadDeltaCrl_Message%>'; return true;" 
  281.                 OnMouseOut="window.status=''; return true;" 
  282.                 OnKeyDown="if (13==event.keyCode) {handleGetDeltaCrl();return false;} else if (9==event.keyCode) {return true;};return false;"
  283.                 OnClick="handleGetDeltaCrl();return false;">
  284.             <LocID ID=locDownloadDeltaCRL>Download latest delta CRL</LocID></Span></Font>
  285.         </TD>
  286.     </TR>
  287. <%End If%>
  288.  
  289. </Table>
  290.     <%Else '"NN"=sBrowser%>
  291. <Table CellSpacing=0 CellPadding=0>
  292.     <TR><TD></TD>
  293.         <TD><Font ID=locInstCaCFont Face="Arial">
  294.             <A Href="#"
  295.                 OnContextMenu="return false;"
  296.                 OnMouseOver="window.status='<%=L_InstallCACert_Message%>'; return true;" 
  297.                 OnMouseOut="window.status=''; return true;" 
  298.                 OnClick="handleInstCert();return false;">
  299.             <LocID ID=locInstallCert>Install CA certificate</LocID></A></Font>
  300.         </TD>
  301.     </TR>
  302.     <TR><TD ColSpan=3 Height=3></TD></TR>
  303.  
  304.     <TR><TD></TD>
  305.         <TD><Font ID=locDlCaCFont2 Face="Arial">
  306.             <A Href="#"
  307.                 OnContextMenu="return false;"
  308.                 OnMouseOver="window.status='<%=L_DownloadCert_Message%>'; return true;" 
  309.                 OnMouseOut="window.status=''; return true;" 
  310.                 OnClick="handleGetCert();return false;">
  311.             <LocID ID=locDownloadCert2>Download CA certificate</LocID></A></Font>
  312.         </TD>
  313.     </TR>
  314.     <TR><TD ColSpan=3 Height=3></TD></TR>
  315.  
  316.     <TR><TD></TD>
  317.         <TD><Font ID=locDlCaCpFont2 Face="Arial">
  318.             <A Href="#"
  319.                 OnContextMenu="return false;"
  320.                 OnMouseOver="window.status='<%=L_DownloadChain_Message%>'; return true;" 
  321.                 OnMouseOut="window.status=''; return true;" 
  322.                 OnClick="handleGetChain();return false;">
  323.             <LocID ID=locDownloadCertChain2>Download CA certificate chain</LocID></A></Font>
  324.         </TD>
  325.     </TR>
  326.     <TR><TD ColSpan=3 Height=3></TD></TR>
  327.  
  328.     <TR><TD></TD>
  329.         <TD><Font ID=locDlBaseCrlFont2 Face="Arial">
  330.             <A Href="#"
  331.                 OnContextMenu="return false;"
  332.                 OnMouseOver="window.status='<%=L_DownloadBaseCrl_Message%>'; return true;" 
  333.                 OnMouseOut="window.status=''; return true;" 
  334.                 OnClick="handleGetBaseCrl();return false;">
  335.             <LocID ID=locDownloadBaseCRL2>Download latest base CRL</LocID></A></Font>
  336.         </TD>
  337.     </TR>
  338.     <TR><TD ColSpan=3 Height=3></TD></TR>
  339.  
  340. <%If True=bDeltaCrl Then %>
  341.     <TR><TD></TD>
  342.         <TD><Font ID=locDlDeltaCrlFont2 Face="Arial">
  343.             <A Href="#"
  344.                 OnContextMenu="return false;"
  345.                 OnMouseOver="window.status='<%=L_DownloadDeltaCrl_Message%>'; return true;" 
  346.                 OnMouseOut="window.status=''; return true;" 
  347.                 OnClick="handleGetDeltaCrl();return false;">
  348.             <LocID ID=locDownloadDeltaCRL2>Download latest delta CRL</LocID></A></Font>
  349.         </TD>
  350.     </TR>
  351. <%End If%>
  352.  
  353. </Table>
  354.     <%End If%>
  355. <%Else '"Text"=sBrowser%>
  356. <!-- Text only: enumerate everything! -->
  357. <DL>
  358. <%For nIndex=0 To nRenewals%>
  359.     <%If CERT_VALID=CInt(rgCertState(nRenewals-nIndex)) Then%>
  360.     <DT><LocID ID=locCaCertHead3>CA Certificate: <%If 0=nIndex Then%><LocID ID=locCurCertEntry3>Current</LocID><%Else%><LocID ID=locPrevCertEntry3>Previous</LocID><%End If%><%If nIndex<>nRenewals Then%> <LocID ID=locCaNameRen3>[<%=sServerDisplayName%>(<%=nRenewals-nIndex%>)]</LocID><%Else%> <LocID ID=locCaNameNoRen3>[<%=sServerDisplayName%>]</LocID><%End If%>
  361.     <DD><LocID ID=locDownloadCert3>Download CA certificate with the following encoding method: </LocID>
  362.             <DD><LocID ID=locSep5>    </LocID><A Href="certnew.cer?ReqID=CACert&Renewal=<%=nRenewals-nIndex%>&Enc=bin"><LocID ID=locDerEnc1>DER</LocID></A><LocID ID=locSep1> </LocID><A Href="certnew.cer?ReqID=CACert&Renewal=<%=nRenewals-nIndex%>&Enc=b64"><LocID ID=locB64Enc1>Base 64</LocID></A><BR>
  363.         <LocID ID=locDownloadCertChain3>Download CA certificate chain with the following encoding method: </LocID>
  364.             <DD><LocID ID=locSep6>    </LocID><A Href="certnew.p7b?ReqID=CACert&Renewal=<%=nRenewals-nIndex%>&Enc=bin"><LocID ID=locDerEnc2>DER</LocID></A><LocID ID=locSep2> </LocID><A Href="certnew.p7b?ReqID=CACert&Renewal=<%=nRenewals-nIndex%>&Enc=b64"><LocID ID=locB64Enc2>Base 64</LocID></A><BR>
  365.         <LocID ID=locDownloadBaseCRL3>Download latest base CRL with the following encoding method: </LocID>
  366.             <DD><LocID ID=locSep7>    </LocID><A Href="certcrl.crl?Type=base&Renewal=<%=GetGoodCrlIndex(nIndex)%>&Enc=bin"><LocID ID=locDerEnc3>DER</LocID></A><LocID ID=locSep3> </LocID><A Href="certcrl.crl?Type=base&Renewal=<%=GetGoodCrlIndex(nIndex)%>&Enc=b64"><LocID ID=locB64Enc3>Base 64</LocID></A><BR>
  367.         <LocID ID=locDownloadDeltaCRL3>Download latest delta CRL with the following encoding method: </LocID>
  368.             <DD><LocID ID=locSep8>    </LocID><A Href="certcrl.crl?Type=delta&Renewal=<%=GetGoodCrlIndex(nIndex)%>&Enc=bin"><LocID ID=locDerEnc4>DER</LocID></A><LocID ID=locSep4> </LocID><A Href="certcrl.crl?Type=delta&Renewal=<%=GetGoodCrlIndex(nIndex)%>&Enc=b64"><LocID ID=locB64Enc4>Base 64</LocID></A><BR>
  369.         <BR>
  370.     <%End If%>
  371. <%Next%>
  372. </DL>
  373. <%End If%>
  374.  
  375. <BR>
  376.     
  377. <!-- Green HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR></Table>
  378. <!-- White HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#FFFFFF><Img Src="certspc.gif" Alt="" Height=5 Width=1></TD></TR></Table>
  379.  
  380. </Form>
  381. </Font>
  382. <!-- ############################################################ -->
  383. <!-- End of standard text. Scripts follow  -->
  384.     
  385. <%bIncludeXEnroll=True%>
  386. <%bIncludeGetCspList=False%>
  387. <!-- #include FILE=certsgcl.inc -->
  388.  
  389. <%If "IE"=sBrowser Then%>
  390. <!-- This form passes data to certrmpn.asp -->
  391. <Span Style="display:none">
  392. <Form Name=SubmittedData Action="certrmpn.asp" Method=Post>
  393. <Input Type=Hidden Name=Action Value="instCA">
  394. <Input Type=Hidden Name=ActionErr Value="OK">
  395. <Input Type=Hidden Name=CertInstalled Value="NO">
  396. </Form>
  397. </Span>
  398. <%End If%>
  399.  
  400. <Script Language="JavaScript">
  401.     //================================================================
  402.     // PAGE GLOBAL VARIABLES
  403.  
  404.     // constants
  405.     var CRL_AVAILABLE=3; // == CA_DISP_VALID
  406.  
  407.     // CA state information
  408.     var nRenewals=<%=nRenewals%>;
  409.     var rgCrlState=new Array(
  410.         <%For nIndex=0 To nRenewals%>
  411.         <%=rgCrlState(nIndex)%><%If nIndex<>nRenewals Then%>,<%End If%>
  412.         <%Next%>
  413.         );
  414.  
  415. <%If "IE"=sBrowser Then%>
  416.     ;
  417.     // Strings To Be Localized
  418.     var L_UnknownInstallFailure_ErrorMessage="\"Unable to install the CA certificate:\\n\\nError: \"+sErrorNumber";
  419.  
  420.     // Cannot install a cert until XEnroll has been loaded
  421.     var g_bXEnrollLoaded=false;
  422.  
  423.     // Prevent attempts to install cert while first install is going
  424.     var g_bInstallingCert=false;
  425.  
  426. <%End If%>
  427.  
  428.     //================================================================
  429.     // LINK HANDLERS
  430.  
  431.     //----------------------------------------------------------------
  432.     // Get the requested cert
  433.     function handleGetCert() {
  434.         location="certnew.cer?ReqID=CACert&Renewal="+getChosenRenewal()+"&"+getEncoding();
  435.     }
  436.     //----------------------------------------------------------------
  437.     // Install the requested cert
  438.     function handleInstCert() {
  439.         location="certnew.cer?ReqID=CACert&Renewal="+getChosenRenewal()+"&Mode=inst&Enc=b64";
  440.     }
  441.     //----------------------------------------------------------------
  442.     // Get the requested certificate chain
  443.     function handleGetChain() {
  444.         location="certnew.p7b?ReqID=CACert&Renewal="+getChosenRenewal()+"&"+getEncoding();
  445.     }
  446.     //----------------------------------------------------------------
  447.     // Get the nearest valid Base CRL
  448.     function handleGetBaseCrl() {
  449.         var nSource=getChosenRenewal();
  450.         while (nSource>0 && CRL_AVAILABLE!=rgCrlState[nSource]) {
  451.             nSource--;
  452.         }
  453.         location="certcrl.crl?Type=base&Renewal="+nSource+"&"+getEncoding();
  454.     }
  455.     //----------------------------------------------------------------
  456.     // Get the nearest valid Delta CRL
  457.     function handleGetDeltaCrl() {
  458.         var nSource=getChosenRenewal();
  459.         while (nSource>0 && CRL_AVAILABLE!=rgCrlState[nSource]) {
  460.             nSource--;
  461.         }
  462.         location="certcrl.crl?Type=delta&Renewal="+nSource+"&"+getEncoding();
  463.     }
  464.     //----------------------------------------------------------------
  465.     // Return the renewal # of the currently chosen cert
  466.     function getChosenRenewal() {
  467.         return nRenewals-document.UIForm.lbCaInstance[document.UIForm.lbCaInstance.selectedIndex].value;
  468.     }
  469.     //----------------------------------------------------------------
  470.     // Return the encoding parameter based upon the radio button
  471.     function getEncoding() {
  472.         if (true==document.UIForm.rbEncoding[0].checked) {
  473.             return "Enc=bin";
  474.         } else {
  475.             return "Enc=b64";
  476.         }
  477.     }
  478.  
  479. <%If "IE"=sBrowser Then%>
  480.     //================================================================
  481.     // INSTALL ROUTINES
  482.  
  483.     //----------------------------------------------------------------
  484.     // IE SPECIFIC:
  485.     // Make sure XEnroll is ready before installing the cert
  486.     function preInstall() {
  487.  
  488.         // prevent double clicking and race conditions
  489.         if (true==g_bInstallingCert) {
  490.             return;
  491.         }
  492.         g_bInstallingCert=true;
  493.  
  494.         if (false==g_bXEnrollLoaded) {
  495.             // XEnroll has never been loaded, so we need to do that first.
  496.  
  497.             // set our special failure handler
  498.             g_fnOnLoadFail=handleLoadFail;
  499.  
  500.             // Load an XEnroll object into the page
  501.             loadXEnroll("preInstallPhase2()"); 
  502.  
  503.         } else {
  504.             // XEnroll is already loaded, so just install the cert
  505.             Install();
  506.         }
  507.     }
  508.     function preInstallPhase2() {
  509.         // continued from above
  510.  
  511.         // Now XEnroll is loaded and we're ready to go.
  512.         g_bXEnrollLoaded=true;
  513.  
  514.         // install the cert
  515.         Install();
  516.     }
  517.  
  518.     //----------------------------------------------------------------
  519.     // IE SPECIFIC:
  520.     // what to to if XEnroll fails to load. In this case, not much.
  521.     function handleLoadFail() {
  522.         // We are done trying to install a cert, so the user can try again.
  523.         // Note that we also *don't* disable controls, since there are no
  524.         //   controls related to installing a cert (just a link)
  525.         g_bInstallingCert=false;
  526.     }
  527.  
  528.     //----------------------------------------------------------------
  529.     // IE SPECIFIC:
  530.     // perform substitution on the error string, because VBScript cannot
  531.     function evalErrorMessage(sErrorNumber) {
  532.         return eval(L_UnknownInstallFailure_ErrorMessage);
  533.     }
  534. <%End If '"IE"=sBrowser%>
  535.  
  536. </Script>
  537.  
  538. <%If "IE"=sBrowser Then%>
  539. <Script Language="VBScript">
  540.     '-----------------------------------------------------------------
  541.     ' IE SPECIFIC:
  542.     ' The current CA Certificate
  543.     Public sPKCS7
  544.     sPKCS7=""
  545. <%=sPKCS7%>
  546.     
  547.     '-----------------------------------------------------------------
  548.     ' IE SPECIFIC:
  549.     ' Install the certificate
  550.     Sub Install()
  551.  
  552.         Dim sMessage
  553.                 Dim CertInstalled
  554.         On Error Resume Next
  555.  
  556.         CertInstalled = XEnroll.InstallPKCS7Ex(sPKCS7)
  557.     
  558.         If 0=Err.Number Then
  559.             ' Certificate has been successfully installed. Go to 'success' page
  560.             document.SubmittedData.submit
  561.         ElseIf -2147023673 = Err.Number Then
  562.             ' if HRESULT_FROM_WIN32(ERROR_CANCELLED), set extra msg
  563.             document.SubmittedData.ActionErr.Value = "Cancel"
  564.             If 0 <> CertInstalled Then
  565.                 document.SubmittedData.CertInstalled = "YES"
  566.             End If
  567.             document.SubmittedData.submit
  568.         Else
  569.             ' unknown error
  570.             sMessage=evalErrorMessage("0x" & Hex(Err.Number))
  571.             Alert sMessage
  572.         End If
  573.         g_bInstallingCert=False
  574.         
  575.     End Sub
  576. </Script>
  577. <%End If '"IE"=sBrowser%>
  578.  
  579. <%End If 'bFailed%>
  580.  
  581. </Body>
  582. </HTML>
  583.